package com.example.phonestore.service.impl;

import com.example.phonestore.entity.Cart;
import com.example.phonestore.entity.City;
import com.example.phonestore.mapper.CityMapper;
import com.example.phonestore.service.CityService;
import com.example.phonestore.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CityServiceImpl implements CityService {

    @Autowired
    private CityMapper cityMapper;
    @Override
    public List<City> getByParent(String parent) {
        List<City> cityList=cityMapper.findByParent(parent);
        for (City c:cityList){
            c.setId(null);
            c.setParent(null);
        }
        return cityList;
    }

    @Override
    public String getNameByCode(String code) {
        return cityMapper.findNameByCode(code);
    }



}
